<?php
class Teacher_model extends MY_Model {
	public function __construct(){
		parent::__construct();	
		$this->setTableName('u_c_teacher');
	}

	public function login($username,$password){
		$r = $this->select('classid,name,password,did','name="'.$username.'" AND password="'.$password.'"','classid desc',1);
		$r = $r[0];
		$this->load->model('department_model');
		$isMinister = $this->department_model->isMinister($r['did'],$r['classid']);
		if($isMinister){
			$r['isMinister']=true;
		}
		return $r;
	}
	public function save($classid,$password){
		$r = $this->update(['password'=>$password],['classid'=>$classid]);
		return $r;
	}
	
	public function teacherList($did){
		$r = $this->select("classid as id,classid as tid,name","did=${did} AND classid not in (SELECT tid FROM wq_u_m_d_t)");
		return $r;
	}
	
	public function info($tid){
		$r = $this->select('*','classid='.$tid);
		return $r[0];
	}
}
?>